#pragma once

#include "arp_context.hpp"
#include "arp_packet.hpp"
#include "limbo/ethernet/state.hpp"

namespace limbo::arp {

template <typename NextState> struct State {
  using Context = ArpContext<State>;
  using Packet = ArpPacket<State>;
  using LowerState = NextState;
  using LowerPacket = details::lower_packet_t<LowerState>;

  Result recv(Chunk buff, LowerState *lower_state) {
    return packet.recv(buff, *this, lower_state);
  }

  Packet &get_parsed() { return packet; }

  inline bool select(const LowerPacket *frame) {
    return frame->type == static_cast<uint16_t>(ethernet::EtherType::arp);
  }

  Packet packet;
};

} // namespace limbo::arp
